/*
 * @Author: your name
 * @Date: 2021-05-25 08:15:14
 * @LastEditTime: 2021-05-25 09:14:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \5.25\logo\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component:()=>import('../views/First'),
    redirect:'/Service',
    children:[
      {
        path:'/Service',
        component:()=>import('../views/Service')
      },
      {
        path:'/Department',
        component:()=>import('../views/Department')
      },
      {
        path:'/Section',
        component:()=>import('../views/Section')
      },
      {
        path:'/Operation',
        component:()=>import('../views/Operation')
      },
      {
        path:'/Database',
        component:()=>import('../views/Database')
      },
      {
        path:'/My',
        component:()=>import('../views/My'),
        beforeEnter : (to,from,next) => {
          const token = window.localStorage.getItem('token')
          if(token){
            next()
          }else{
            next('/Login')
          }
        }
      }
    ]
  },
  {
    path:'/Detail',
    component:()=>import('../views/Detail')
  },
  {
    path:'/Login',
    component:()=>import('../views/Login')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
